const db = require('mongoose')
class dbb {
  constructor() {
    db.connect('mongodb://127.0.0.1:27017/fruitTea').then(res => {
      console.log('数据库连接成功');
      //开启调试模式
      db.set('debug', true)
    }).catch(err => {
      console.log('数据库连接失败' + err);
    })
  }
  // 创建数据模型
  createModel(schemaObj, tbName) {
    const schema = new db.Schema(schemaObj)
    return db.model(tbName, schema, tbName)
  }
}
module.exports = dbb